﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using HigLabo.WindowsAzure.RestService.Extensions;

namespace HigLabo.WindowsAzure.RestService.ServiceManagement
{
    public class UpgradeStatus
    {
        public static readonly String ElementName = "UpgradeStatus";

        public UpgradeType UpgradeType { get; private set; }
        public CurrentUpgradeDomainState CurrentUpgradeDomainState { get; private set; }
        public Int32 CurrentUpgradeDomain { get; private set; }

        public UpgradeStatus(XElement xml)
        {
            if (xml == null)
            {
                throw new ArgumentNullException("xml");
            }
            this.UpgradeType = xml.ValueToEnum("UpgradeType", UpgradeType.Auto);
            this.CurrentUpgradeDomainState = xml.ValueToEnum("CurrentUpgradeDomainState", CurrentUpgradeDomainState.Before);
            this.CurrentUpgradeDomain = xml.ValueToInt32("CurrentUpgradeDomain", 0);
        } 
    }
}
